import java.util.Scanner;

public class test {
    //两个数相加
    public static int add(int a,int b){
        return a + b;
    }
    //三个小数相加
    public static int add(int a,int b,int c){
        return a + b + c;
    }

    public static void main1(String[] args) {
        int x = 1;
        int y = 2;
        int ret = add(x,y);
        double a = 1.0;
        double c = 2.0;
        double b = 3.0;
        System.out.println("两个："+ ret);
        System.out.println("三个:" );
    }
    public static int max(int a,int b){
        if(a < b){
            int t = a;
            a = b;
            b = t;
        }
        return a;
    }
    public static int max(int a,int b,int c) {
        if(a < b){
            int t = a;
            a = b;
            b = t;
        }
        if(a < c){
            int t = a;
            a = c;
            c = t;
        }
        return a;
    }

    public static void main2(String[] args) {
    int x = 3;
    int y = 2;
    int z = 6;
    int ret = max(x,y);
    int m = max(x,y,z);
        System.out.println(ret);
        System.out.println(m);
    }
    public static int funN(int n){
        if(n <= 0){
            return 1;
        }
        else {
            return n*funN(n-1);
        }
    }

    public static int add(int n){
        if(n <= 1){
            return 1;
        }
        else {
            return n + add(n-1);
        }
    }
    public static void Print(int n){
        if(n > 9){
            Print(n/10);
        }
        System.out.println(n%10);
    }
    public static int sum(int n){
        /*int sum = 0;//迭代
        while(n > 0){
            sum += n % 10;
            n /= 10;
        }
        System.out.println(sum);*/
        //递归
        if(n < 10){
            return n;
        }
        else {
            return n%10 + sum(n/10);
        }
    }
    public static int fun(int n){
        if(n <= 2){
            return 1;
        }
        else {
            return fun(n-1) + fun(n-2);
        }
    }
    public static void move(char pos1,char pos2){
        System.out.print(pos1 + "->"+pos2 + ' ');
    }

    /**
     *
     * @param n 盘子个数
     * @param pos1 初始位置
     * @param pos2 中转位置
     * @param pos3 目标位置
     */
    public static void hanio(int n,char pos1,char pos2,char pos3){
        if(n == 1){
            move(pos1,pos3);
        }
        else {
            hanio(n-1,pos1,pos3,pos2);
            move(pos1,pos3);
            hanio(n-1,pos2,pos1,pos3);
        }
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        hanio(1,'A','B','C');
        System.out.println();
        hanio(2,'A','B','C');
        System.out.println();
        hanio(3,'A','B','C');
    }
}
